Typically a conventional two dimensional discrete cosine transform (2D-DCT) is applied to prediction residuals associated with a template matched intra-coding scheme. However, use of the 2D-DCT is questionable because the discrete cosine transform (DCT) basis functions get to the maximal magnitude at both ends and are agnostic to the statistical characteristics of the residuals. As a result, there is a need for a template matched intra-coding scheme where the statistical characteristics of the residuals are taken into consideration.